Page({
  data:{

  },
  formSubmit:function(e){
     var user = e.detail.value;
     var name = user.name;
     var password = user.password;
     //var users = wx.getStorageSync("users");
     wx.request({
      url: 'http://127.0.0.1:8080/getAllUser_wx',
      method:'GET',
      header:{
        "Content-Type":"json"
      },
      success:function(res){
         console.log(res);
         var users = new Array();
         var subjects = res.data.data;
         var len = subjects.length >=10?10:subjects.length;
         for(var i=0;i<len;i++){
            var subject = subjects[i];
            var user = new Object();
            user.name = subject.User_name;
            user.password = subject.User_pwd;
           
            users.push(user);

         }
         //console.log(movies);
        // page.setData({movies:movies});
        for(var i=0;i<users.length;i++){
          if(name==users[i].name && password == users[i].password){
            user=users[i];
            console.log(user);
            wx.setStorageSync("user", user);
            wx.showToast({
              title: '登录成功',
              icon: 'success',
              duration: 1000
            });
            wx.navigateBack({
              delta: 1
            })
            break;
          }
       }
      }
    })

     
  }
})